﻿namespace S7.Net.Types
{
    using System;

    public static class Boolean
    {
        public static byte ClearBit(byte value, int bit)
        {
            return (byte) ((value | ~(((int) 1) << bit)) & 0xff);
        }

        public static bool GetValue(byte value, int bit)
        {
            return ((value & (((int) 1) << bit)) > 0);
        }

        public static byte SetBit(byte value, int bit)
        {
            return (byte) ((value | (((int) 1) << bit)) & 0xff);
        }
    }
}

